import { useEffect, useState } from 'react';
import { View, Text, Image, Input, Button, Radio, Label } from '@tarojs/components'
import { AtAvatar, AtInput, AtForm, AtButton, message } from 'taro-ui'
import "taro-ui/dist/style/components/button.scss" // 按需引入
import "./register.scss"
import http from '../../utils/http';


const Register = () => {
  const Jump = () => {
    wx.navigateTo({
      url: '../login/login',
    })
  }
  let ph
  let yzm
  let ps
  const onChange = (value) => {
    ph = value.detail.value
    // console.log(value.detail.value);
    // console.log(ph);
  }
  const onYzm = (value) => {
    yzm = value.detail.value
    // console.log(value.detail.value);
    // console.log(yzm);
  }
  const onPs = (value) => {
    ps = value.detail.value
    // console.log(value.detail.value);
    // console.log(ps);
  }

  const Reg = (values) => {
    http({
      url: '/role/register',
      data: {
        phone: ph,
        Password: ps,
        yzm: yzm

      },
      method: "post"
    }).then((res) => {
      console.log(res.data)
      if (res.code == 200) {
        // message.success('注册成功')
        wx.navigate({
          url: './login/login'
        })
      }
    })
    console.log("success", values);
  }
  return <View>
    <View className='header'>
      <Text>账号注册</Text>
      <AtAvatar image='https://jdc.jd.com/img/200' size='' circle='true'></AtAvatar>
    </View>
    <View>
      <Input type='number' placeholder='请输入手机号码' onInput={onChange} />
      <View className='yzm'>
        <Input placeholder='请输入验证码' onInput={onYzm} />
        <AtButton size='small' type='primary' circle className='btn'>发送验证码</AtButton>
      </View>
      <Input type='password' placeholder='请设置登录密码' onInput={onPs} />

    </View>
    <AtButton size='normal' type='primary' circle className='ok' onClick={Reg}>注册</AtButton>

    <View className='checked'>
      <Radio value='选中' checked></Radio>
      <Text>已阅读并同意<Text className='xieyi'>《用户协议》</Text>和<Text className='xieyi'>《隐私政策》</Text></Text>
    </View>
    <View className='foot'>
      <Text onClick={Jump}>已有账号立即登录</Text>
    </View>

  </View>
}
export default Register